package com.bluemobi.ssm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bluemobi.ssm.data.${toClassName}Mapper;
import com.bluemobi.ssm.model.${toClassName};
<#if hasCompositePk&&primeType!=toClassName>import com.bluemobi.ssm.model.${toClassName}Id;</#if>
import com.bluemobi.ssm.service.${toClassName}Service;

/**
*
* @ClassName: ${toClassName}
* @Description: ${toClassName}增删改查实现类
* @author
* @date
*
*/
@Service
public class ${toClassName}ServiceImpl implements ${toClassName}Service {

//装配${toClassName}
@Autowired
private ${toClassName}Mapper ${toEntityName}Mapper;

@Override
public List<${toClassName}> getAll${toClassName}s() {
return ${toEntityName}Mapper.selectAll();
}

@Override
public List<${toClassName}> get${toClassName}sByCondition(${toClassName} ${toEntityName}) {
return ${toEntityName}Mapper.selectByCondition(${toEntityName});
}

@Override
public ${toClassName} find${toClassName}ById(${primeType} primeKey) {
return ${toEntityName}Mapper.selectSingle(primeKey);
}

@Override
public long total${toClassName}s(${toClassName} ${toEntityName}) {
return ${toEntityName}Mapper.selectTotal(${toEntityName});
}
<#if hasFieldAutoIncrease>
@Override
public ${toClassName} addNew${toClassName}(${toClassName} ${toEntityName}) {
if(${toEntityName}Mapper.save(${toEntityName})>0){
return ${toEntityName};
}else{
return null;
}
}
<#else>
@Override
public void addNew${toClassName}(${toClassName} ${toEntityName}) {
${toEntityName}Mapper.save(${toEntityName});
}
</#if>
@Override
public void remove${toClassName}ById(${primeType} primeKey) {
${toEntityName}Mapper.delete(primeKey);
}

@Override
public void modify${toClassName}(${toClassName} ${toEntityName}) {
${toEntityName}Mapper.update(${toEntityName});
}

}
